<template>
  <div class="pt-5 pb-5 pl-2 text-2xl large">{{ $t("必填信息") }}</div>
  <el-form
    :model="enterpriseUserForm"
    label-width="170px"
    label-position="left"
    ref="formRef"
    :rules="rules"
  >
    <el-row :gutter="20">
      <el-col :span="12">
        <el-form-item :label="$t('企业名称')" required prop="company_name">
          <el-input
            v-model="enterpriseUserForm.company_name"
            :placeholder="$t('请输入企业名称')"
            clearable
          />
        </el-form-item>
      </el-col>
      <el-col :span="12">
        <el-form-item :label="$t('银行名称')" required prop="bank_name">
          <el-input
            v-model="enterpriseUserForm.bank_name"
            :placeholder="$t('请输入银行名称')"
            clearable
          />
        </el-form-item>
      </el-col>
    </el-row>
    <el-row :gutter="20">
      <el-col :span="12">
        <el-form-item :label="$t('付款方式')" required prop="pay_way">
          <el-input
            v-model="enterpriseUserForm.pay_way"
            :placeholder="$t('请输入付款方式')"
            clearable
          />
        </el-form-item>
      </el-col>
      <el-col :span="12">
        <el-form-item :label="$t('银行国家/地区')" required prop="bank_country">
          <el-input
            v-model="enterpriseUserForm.bank_country"
            :placeholder="$t('请输入银行国家/地区')"
            clearable
          />
        </el-form-item>
      </el-col>
    </el-row>
    <el-row :gutter="20">
      <!-- 收款国家/地区" -->
      <el-col :span="12">
        <el-form-item
          :label="$t('收款人国家/地区')"
          required
          prop="receive_country"
        >
          <el-input
            v-model="enterpriseUserForm.receive_country"
            :placeholder="$t('请输入收款人国家/地区')"
            clearable
          />
        </el-form-item>
      </el-col>
      <el-col :span="12">
        <el-form-item :label="$t('银行城市')" required prop="bank_city">
          <el-input
            v-model="enterpriseUserForm.bank_city"
            :placeholder="$t('请输入银行城市')"
            clearable
          />
        </el-form-item>
      </el-col>
    </el-row>
    <el-row :gutter="20">
      <el-col :span="12">
        <el-form-item :label="$t('收款人地址')" required prop="receive_address">
          <el-input
            v-model="enterpriseUserForm.receive_address"
            :placeholder="$t('请输入收款人地址')"
            clearable
          />
        </el-form-item>
      </el-col>
      <el-col :span="12">
        <el-form-item :label="$t('银行地址')" required prop="bank_address">
          <el-input
            v-model="enterpriseUserForm.bank_address"
            :placeholder="$t('请输入银行地址')"
            clearable
          />
        </el-form-item>
      </el-col>
    </el-row>
    <el-row :gutter="20">
      <el-col :span="12">
        <el-form-item :label="$t('银行账号')" required prop="bank_card_number">
          <el-input
            v-model="enterpriseUserForm.bank_card_number"
            :placeholder="$t('请输入银行账号')"
            clearable
          />
        </el-form-item>
      </el-col>
      <el-col :span="12">
        <el-form-item :label="$t('币种')" required prop="currency">
          <el-select
            v-model="enterpriseUserForm.currency"
            :placeholder="$t('请选择币种')"
            clearable
          >
            <el-option
              v-for="item in currencyList"
              :key="item.key"
              :label="item.name"
              :value="item.symbol"
            ></el-option>
          </el-select>
        </el-form-item>
      </el-col>
    </el-row>
    <el-row :gutter="20">
      <el-col :span="12">
        <el-form-item :label="$t('IBAN码')" required prop="bank_iban">
          <el-input
            v-model="enterpriseUserForm.bank_iban"
            :placeholder="$t('请输入IBAN码')"
            clearable
          />
        </el-form-item>
      </el-col>
      <el-col :span="12">
        <el-form-item :label="$t('SWIFT码')" required prop="bank_swift">
          <el-input
            v-model="enterpriseUserForm.bank_swift"
            :placeholder="$t('请输入SWIFT码')"
            clearable
          />
        </el-form-item>
      </el-col>
    </el-row>

    <!-- 企业真实姓名联系方式 -->
    <el-divider />
    <el-row :gutter="20">
      <el-col :span="12">
        <el-form-item :label="$t('真实姓名')">
          <el-input
            v-model="enterpriseUserForm.real_name"
            :placeholder="$t('请输入真实姓名')"
            clearable
          />
        </el-form-item>
      </el-col>
    </el-row>
    <el-row :gutter="20">
      <el-col :span="12">
        <el-form-item :label="$t('联系方式')">
          <el-input
            v-model="enterpriseUserForm.contact"
            :placeholder="$t('请输入联系方式')"
            clearable
          />
        </el-form-item>
      </el-col>
    </el-row>
    <el-form-item :label="$t('个人证件照')">
      <!-- :action="config.config.img_upload" -->
      <div
        class="el-upload--picture-card el-upload-list el-upload-list--picture-card"
        v-if="enterpriseUserForm.file_idcard_front && !fileIdcardFrontBtn"
      >
        <div class="el-upload-list__item is-success">
          <img
            class="el-upload-list__item-thumbnail"
            :src="
              enterpriseUserForm.file_host +
              enterpriseUserForm.file_idcard_front
            "
            alt=""
          />
          <span class="el-upload-list__item-actions">
            <span
              class="el-upload-list__item-delete"
              @click="
                handleRemove(enterpriseUserForm.file_idcard_front, '正面')
              "
            >
              <el-icon>
                <Delete />
              </el-icon>
            </span>
          </span>
        </div>
      </div>
      <el-upload
        ref="fileIdcardFrontRef"
        :class="{ front_box: fileIdcardFrontBtn }"
        :action="config.img_upload"
        list-type="picture-card"
        v-else
        :limit="1"
        :on-success="handleFrontImgSuccess"
        :on-change="
          (file) => {
            handleChange(file, '正面');
          }
        "
        :headers="TOKENT_HEADER"
      >
        <el-icon>
          <Plus />
        </el-icon>
        <div>{{ $t("请上传个人证件正面图片") }}</div>
        <template #file="{ file }">
          <div>
            <img
              class="el-upload-list__item-thumbnail"
              :src="file.url"
              alt=""
            />
            <span class="el-upload-list__item-actions">
              <span
                class="el-upload-list__item-delete"
                @click="handleRemove(file, '正面')"
              >
                <el-icon>
                  <Delete />
                </el-icon>
              </span>
            </span>
          </div>
        </template>
      </el-upload>
      <div class="uploadDiv" />
      <div
        class="el-upload--picture-card el-upload-list el-upload-list--picture-card"
        v-if="enterpriseUserForm.file_idcard_back && !fileIdcardBackBtn"
      >
        <div class="el-upload-list__item is-success">
          <img
            class="el-upload-list__item-thumbnail"
            :src="
              enterpriseUserForm.file_host + enterpriseUserForm.file_idcard_back
            "
            alt=""
          />
          <span class="el-upload-list__item-actions">
            <span
              class="el-upload-list__item-delete"
              @click="handleRemove(enterpriseUserForm.file_idcard_back, '反面')"
            >
              <el-icon>
                <Delete />
              </el-icon>
            </span>
          </span>
        </div>
      </div>
      <el-upload
        ref="fileIdcardBackRef"
        :class="{ back_box: fileIdcardBackBtn }"
        :action="config.img_upload"
        list-type="picture-card"
        :on-success="handleBackImgSuccess"
        v-else
        :limit="1"
        :on-change="
          (file) => {
            handleChange(file, '反面');
          }
        "
        :headers="TOKENT_HEADER"
      >
        <el-icon>
          <Plus />
        </el-icon>
        <div>{{ $t("请上传个人证件背面图片") }}</div>
        <template #file="{ file }">
          <div>
            <img
              class="el-upload-list__item-thumbnail"
              :src="file.url"
              alt=""
            />
            <span class="el-upload-list__item-actions">
              <span
                class="el-upload-list__item-delete"
                @click="handleRemove(file, '反面')"
              >
                <el-icon>
                  <Delete />
                </el-icon>
              </span>
            </span>
          </div>
        </template>
      </el-upload>
      <div class="uploadDiv" />
      <div
        class="el-upload--picture-card el-upload-list el-upload-list--picture-card"
        v-if="enterpriseUserForm.file_idcard_hand && !fileIdcardHandBtn"
      >
        <div class="el-upload-list__item is-success">
          <img
            class="el-upload-list__item-thumbnail"
            :src="
              enterpriseUserForm.file_host + enterpriseUserForm.file_idcard_hand
            "
            alt=""
          />
          <span class="el-upload-list__item-actions">
            <span
              class="el-upload-list__item-delete"
              @click="handleRemove(enterpriseUserForm.file_idcard_hand, '手持')"
            >
              <el-icon>
                <Delete />
              </el-icon>
            </span>
          </span>
        </div>
      </div>

      <el-upload
        ref="fileIdcardHandRef"
        :class="{ hand_box: fileIdcardHandBtn }"
        :action="config.img_upload"
        list-type="picture-card"
        :on-success="handleHandImgSuccess"
        v-else
        :limit="1"
        :on-change="
          (file) => {
            handleChange(file, '手持');
          }
        "
        :headers="TOKENT_HEADER"
      >
        <el-icon>
          <Plus />
        </el-icon>
        <div>{{ $t("请上传手持证件图片") }}</div>
        <template #file="{ file }">
          <div>
            <img
              class="el-upload-list__item-thumbnail"
              :src="file.url"
              alt=""
            />
            <span class="el-upload-list__item-actions">
              <span
                class="el-upload-list__item-delete"
                @click="handleRemove(file, '手持')"
              >
                <el-icon>
                  <Delete />
                </el-icon>
              </span>
            </span>
          </div>
        </template>
      </el-upload>
    </el-form-item>
    <el-divider />

    <div class="pt-5 pb-5 pl-2 text-2xl large">
      {{ $t("选填信息") }}
      <!--<span class="text-sm">{{$t('以下KYC资料可发送至邮箱')}}：wanglu@travel-linker.com</span>-->
    </div>
    <el-row :gutter="20">
      <el-col :span="12">
        <el-form-item :label="$t('公司注册证书')" label-width="250px">
          <el-upload
            :limit="1"
            :action="config.img_upload"
            ref="fileCompanyCertificateRef"
            :on-success="handleCompanyCertificateImgSuccess"
            :on-remove="handleCompanyCertificateImgRemove"
            :headers="TOKENT_HEADER"
          >
            <el-button
              type="primary"
              :icon="Upload"
              v-if="!enterpriseUserForm.file_company_certificate"
              >{{ $t("点击上传") }}</el-button
            >
          </el-upload>
        </el-form-item>
      </el-col>
      <el-col :span="12">
        <el-form-item :label="$t('公司地址证明(近3个月)')" label-width="350px">
          <el-upload
            :limit="1"
            :action="config.img_upload"
            ref="fileCompanyAddressRef"
            :on-success="handleCompanyAddressImgSuccess"
            :on-remove="handleCompanyAddressImgRemove"
            :headers="TOKENT_HEADER"
          >
            <el-button
              type="primary"
              :icon="Upload"
              v-if="!enterpriseUserForm.file_company_address"
              >{{ $t("点击上传") }}</el-button
            >
          </el-upload>
        </el-form-item>
      </el-col>
    </el-row>

    <el-row :gutter="20">
      <el-col :span="12">
        <el-form-item :label="$t('最新商业登记证')" label-width="250px">
          <el-upload
            :limit="1"
            :action="config.img_upload"
            ref="fileLatestRegisterRef"
            :on-success="handleLatestRegisterImgSuccess"
            :on-remove="handleLatestRegisterImgRemove"
            :headers="TOKENT_HEADER"
          >
            <el-button
              type="primary"
              :icon="Upload"
              v-if="!enterpriseUserForm.file_latest_register"
              >{{ $t("点击上传") }}</el-button
            >
          </el-upload>
        </el-form-item>
      </el-col>
      <el-col :span="12">
        <el-form-item :label="$t('银行对账单(近3个月)')" label-width="350px">
          <el-upload
            :limit="1"
            :action="config.img_upload"
            ref="fileBankStatementRef"
            :on-success="handleBankStatementImgSuccess"
            :on-remove="handleBankStatementImgRemove"
            :headers="TOKENT_HEADER"
          >
            <el-button
              type="primary"
              :icon="Upload"
              v-if="!enterpriseUserForm.file_bank_statement"
              >{{ $t("点击上传") }}</el-button
            >
          </el-upload>
        </el-form-item>
      </el-col>
    </el-row>

    <el-row :gutter="20">
      <el-col :span="12">
        <el-form-item :label="$t('最新年审报告')" label-width="250px">
          <el-upload
            :limit="1"
            :action="config.img_upload"
            ref="fileLatestReportRef"
            :on-success="handleLatestReportImgSuccess"
            :on-remove="handleLatestReportImgRemove"
            :headers="TOKENT_HEADER"
          >
            <el-button
              type="primary"
              :icon="Upload"
              v-if="!enterpriseUserForm.file_latest_report"
              >{{ $t("点击上传") }}</el-button
            >
          </el-upload>
        </el-form-item>
      </el-col>
      <el-col :span="12">
        <el-form-item
          :label="$t('采购供应商协议及发票(有效期内)')"
          label-width="350px"
        >
          <el-upload
            :limit="1"
            :action="config.img_upload"
            ref="fileSupplierAgreementRef"
            :on-success="handleSupplierAgreementImgSuccess"
            :on-remove="handleSupplierAgreementImgRemove"
            :headers="TOKENT_HEADER"
          >
            <el-button
              type="primary"
              :icon="Upload"
              v-if="!enterpriseUserForm.file_supplier_agreement"
              >{{ $t("点击上传") }}</el-button
            >
          </el-upload>
        </el-form-item>
      </el-col>
    </el-row>

    <el-row :gutter="20">
      <el-col :span="12">
        <el-form-item :label="$t('最新财务报表/税表')" label-width="250px">
          <el-upload
            :limit="1"
            :action="config.img_upload"
            ref="fileFinancialStatementsRef"
            :on-success="handleFinancialStatementsImgSuccess"
            :on-remove="handleFinancialStatementsImgRemove"
            :headers="TOKENT_HEADER"
          >
            <el-button
              type="primary"
              :icon="Upload"
              v-if="!enterpriseUserForm.file_financial_statements"
              >{{ $t("点击上传") }}</el-button
            >
          </el-upload>
        </el-form-item>
      </el-col>
      <el-col :span="12">
        <el-form-item
          :label="$t('销售协议及发票(有效期内)')"
          label-width="350px"
        >
          <el-upload
            :limit="1"
            :action="config.img_upload"
            ref="fileSaleAgreementRef"
            :on-success="handleSaleAgreementImgSuccess"
            :on-remove="handleSaleAgreementImgRemove"
            :headers="TOKENT_HEADER"
          >
            <el-button
              type="primary"
              :icon="Upload"
              v-if="!enterpriseUserForm.file_sale_agreement"
              >{{ $t("点击上传") }}</el-button
            >
          </el-upload>
        </el-form-item>
      </el-col>
    </el-row>

    <el-row :gutter="20">
      <el-col :span="12">
        <el-form-item
          :label="$t('所有持股10%以上股东的有效证件')"
          label-width="250px"
        >
          <el-upload
            :limit="1"
            :action="config.img_upload"
            ref="fileStockCertificateRef"
            :on-success="handleStockCertificateImgSuccess"
            :on-remove="handleStockCertificateImgRemove"
            :headers="TOKENT_HEADER"
          >
            <el-button
              type="primary"
              :icon="Upload"
              v-if="!enterpriseUserForm.file_stock_certificate"
              >{{ $t("点击上传") }}</el-button
            >
          </el-upload>
        </el-form-item>
      </el-col>
      <el-col :span="12">
        <el-form-item
          :label="$t('开户授权签字人有效证件+签字印鉴')"
          label-width="350px"
        >
          <el-upload
            :limit="1"
            :action="config.img_upload"
            ref="fileKaihuZhengjianRef"
            :on-success="handleKaihuZhengjianImgSuccess"
            :on-remove="handleKaihuZhengjianImgRemove"
            :headers="TOKENT_HEADER"
          >
            <el-button
              type="primary"
              :icon="Upload"
              v-if="!enterpriseUserForm.file_kaihu_zhengjian"
              >{{ $t("点击上传") }}</el-button
            >
          </el-upload>
        </el-form-item>
      </el-col>
    </el-row>

    <el-row :gutter="20">
      <el-col :span="12">
        <el-form-item :label="$t('INVOICE范本')" label-width="250px">
          <el-upload
            :limit="1"
            :action="config.img_upload"
            ref="fileNvoiceRef"
            :on-success="handleNvoiceImgSuccess"
            :on-remove="handleNvoiceImgRemove"
            :headers="TOKENT_HEADER"
          >
            <el-button
              type="primary"
              :icon="Upload"
              v-if="!enterpriseUserForm.file_invoice"
              >{{ $t("点击上传") }}</el-button
            >
          </el-upload>
        </el-form-item>
      </el-col>
      <el-col :span="12">
        <el-form-item
          :label="$t('开户授权签字人个人地址证明(近3个月)')"
          label-width="350px"
        >
          <el-upload
            :limit="1"
            :action="config.img_upload"
            ref="fileKaihuZhengjianAddrRef"
            :on-success="handleKaihuZhengjianAddrImgSuccess"
            :on-remove="handleKaihuZhengjianAddrImgRemove"
            :headers="TOKENT_HEADER"
          >
            <el-button
              type="primary"
              :icon="Upload"
              v-if="!enterpriseUserForm.file_kaihu_zhengjian_addr"
              >{{ $t("点击上传") }}</el-button
            >
          </el-upload>
        </el-form-item>
      </el-col>
    </el-row>

    <el-row :gutter="20">
      <el-col :span="12">
        <el-form-item :label="$t('董事地址证明(近3个月)')" label-width="250px">
          <el-upload
            :limit="1"
            :action="config.img_upload"
            ref="fileBoardMemberAddressRef"
            :on-success="handleBoardMemberAddressImgSuccess"
            :on-remove="handleBoardMemberAddressImgRemove"
            :headers="TOKENT_HEADER"
          >
            <el-button
              type="primary"
              :icon="Upload"
              v-if="!enterpriseUserForm.file_board_member_address"
              >{{ $t("点击上传") }}</el-button
            >
          </el-upload>
        </el-form-item>
      </el-col>
      <el-col :span="12">
        <el-form-item :label="$t('公司组织架构')" label-width="350px">
          <el-upload
            :limit="1"
            :action="config.img_upload"
            ref="fileCompanyOrganizationRef"
            :on-success="handleCompanyOrganizationImgSuccess"
            :on-remove="handleCompanyOrganizationImgRemove"
            :headers="TOKENT_HEADER"
          >
            <el-button
              type="primary"
              :icon="Upload"
              v-if="!enterpriseUserForm.file_company_organization"
              >{{ $t("点击上传") }}</el-button
            >
          </el-upload>
        </el-form-item>
      </el-col>
    </el-row>
  </el-form>

  <!-- 企业用户提交按钮 -->
  <div class="flex justify-center mt-5" v-cloak>
    <el-button
      type="primary"
      :icon="SuccessFilled"
      @click="handleSubmit"
      class="w-60"
      v-if="
        enterpriseUserForm.mer_review_status === 0 ||
        enterpriseUserForm.mer_review_status === 2
      "
    >
      {{ $t("提交审核") }}
    </el-button>
    <el-button
      type="warning"
      :icon="EditPen"
      @click="handleSave"
      v-if="
        enterpriseUserForm.mer_review_status === 0 ||
        enterpriseUserForm.mer_review_status === 2
      "
    >
      {{ $t("保存") }}
    </el-button>
  </div>
</template>
<script setup>
import { ref, computed } from "vue";
import { ElMessage } from "element-plus";
import { config, TOKENT_HEADER } from "@/config/index";
import {
  Plus,
  Delete,
  EditPen,
  SuccessFilled,
  Upload,
} from "@element-plus/icons-vue";
import { getCurrencyNewApi } from "@/api/exchange/index";
import { useI18n } from "vue-i18n";
const { t } = useI18n();
const formRef = ref();

const emits = defineEmits([
  "submitEnterpriseUserForm",
  "enterprisePersonSubmit",
]);
const fileCompanyCertificateRef = ref(); //公司注册证书
const fileCompanyAddressRef = ref(); //公司地址证明(近3个月)
const fileLatestRegisterRef = ref(); //最新商业登记证
const fileBankStatementRef = ref(); //银行对账单(近3个月)
const fileLatestReportRef = ref(); //最新年审报告
const fileSupplierAgreementRef = ref(); //供应商协议及发票（有效期内）
const fileFinancialStatementsRef = ref(); //最新财务报表/税表
const fileSaleAgreementRef = ref(); //销售协议及发票（有效期内）
const fileStockCertificateRef = ref(); //所有持股10%以上股东有效证件
const fileKaihuZhengjianRef = ref(); //开户授权签字人有效证件（有效期内+签字印鉴）
const fileNvoiceRef = ref(); //NVOICE范本

const fileKaihuZhengjianAddrRef = ref(); //开户授权签字人个人地址证明（近3个月）
const fileBoardMemberAddressRef = ref(); //董事地址证明(近3个月)
const fileCompanyOrganizationRef = ref(); //公司组织架构

const fileIdcardFrontRef = ref(); //身份证正面Ref 用于清楚删除操作
const fileIdcardBackRef = ref(); //身份证反面Ref 用于清楚删除操作
const fileIdcardHandRef = ref(); //手持身份证Ref 用于清楚删除操作
const fileIdcardFrontBtn = ref(false); //身份证正面class 用于上传以后隐藏上传按钮
const fileIdcardBackBtn = ref(false); //身份证反面class 用于上传以后隐藏上传按钮
const fileIdcardHandBtn = ref(false); //手持身份证class 用于上传以后隐藏上传按钮

const currencyList = ref([]); // 币种
const props = defineProps({
  enterpriseUserForm: {
    type: Object,
    default: {
      account_type: 1,
      company_name: "",
      pay_way: "",
      receive_country: "",
      receive_address: "",
      bank_name: "",
      bank_country: "",
      bank_city: "",
      bank_address: "",
      // receive_city:"",
      bank_swift: "",
      bank_iban: "",
      bank_card_number: "",
      currency: "",

      file_company_certificate: "",
      file_company_address: "",
      file_latest_register: "",
      file_bank_statement: "",
      file_latest_report: "",
      file_supplier_agreement: "",
      file_financial_statements: "",
      file_sale_agreement: "",
      file_stock_certificate: "",
      file_kaihu_zhengjian: "",
      // file_nvoice: "",
      file_invoice: "",
      file_kaihu_zhengjian_addr: "",
      file_board_member_address: "",
      file_company_organization: "",
      mer_review_status: 0,
      real_name: "",
      contact: "",
      file_idcard_front: "",
      file_idcard_back: "",
      file_idcard_hand: "",
    },
  },
});
// 校验
const rules = computed(() => {
  return {
    company_name: [
      { required: true, message: t("请输入企业名称"), trigger: "blur" },
    ],
    bank_name: [
      { required: true, message: t("请输入银行名称"), trigger: "blur" },
    ],
    pay_way: [
      { required: true, message: t("请输入付款方式"), trigger: "blur" },
    ],
    bank_country: [
      { required: true, message: t("请输入银行国家/地区"), trigger: "blur" },
    ],
    receive_country: [
      { required: true, message: t("请输入收款人国家/地区"), trigger: "blur" },
    ],
    bank_city: [
      { required: true, message: t("请输入银行城市"), trigger: "blur" },
    ],
    receive_address: [
      { required: true, message: t("请输入收款人地址"), trigger: "blur" },
    ],
    bank_address: [
      { required: true, message: t("请输入银行地址"), trigger: "blur" },
    ],

    bank_card_number: [
      { required: true, message: t("请输入银行账号"), trigger: "blur" },
    ],
    currency: [{ required: true, message: t("请选择币种"), trigger: "blur" }],
    //    bank_iban: [{ required: true, message: t("请输入IBAN码"), trigger: "blur" }],
    bank_swift: [
      { required: true, message: t("请输入SWIFT码"), trigger: "blur" },
    ],
  };
});

const handleFrontImgSuccess = (res) => {
  if (res.code === 0) {
    ElMessage({
      message: t("上传成功"),
      type: "success",
    });
    props.enterpriseUserForm.file_idcard_front = res.data.name;
  } else {
    ElMessage({
      message: t("上传失败"),
      type: "error",
    });
    return false;
  }
};
// 个人证件反面照片上传成功
const handleBackImgSuccess = (res) => {
  if (res.code === 0) {
    ElMessage({
      message: t("上传成功"),
      type: "success",
    });
    props.enterpriseUserForm.file_idcard_back = res.data.name;
  } else {
    ElMessage({
      message: t("上传失败"),
      type: "error",
    });
    return false;
  }
};
// 个人证件手持上传成功
const handleHandImgSuccess = (res) => {
  if (res.code === 0) {
    ElMessage({
      message: t("上传成功"),
      type: "success",
    });
    props.enterpriseUserForm.file_idcard_hand = res.data.name;
  } else {
    ElMessage({
      message: t("上传失败"),
      type: "error",
    });
    return false;
  }
};
const handleChange = (file, type) => {
  // console.log(file);
  switch (type) {
    case "正面":
      fileIdcardFrontBtn.value = true;
      break;
    case "反面":
      fileIdcardBackBtn.value = true;
      break;
    case "手持":
      fileIdcardHandBtn.value = true;
      break;
  }
};
const handleRemove = (file, type) => {
  switch (type) {
    case "正面":
      fileIdcardFrontRef.value ? fileIdcardFrontRef.value.clearFiles() : "";
      fileIdcardFrontBtn.value = false;
      props.enterpriseUserForm.file_idcard_front = "";
      break;
    case "反面":
      fileIdcardBackRef.value ? fileIdcardBackRef.value.clearFiles() : "";
      fileIdcardBackBtn.value = false;
      props.enterpriseUserForm.file_idcard_back = "";
      break;
    case "手持":
      fileIdcardHandRef.value ? fileIdcardHandRef.value.clearFiles() : "";
      fileIdcardHandBtn.value = false;
      props.enterpriseUserForm.file_idcard_hand = "";
      break;
  }
};

// 公司注册证书上传
const handleCompanyCertificateImgSuccess = (res) => {
  if (res.code === 0) {
    ElMessage({
      message: t("上传成功"),
      type: "success",
    });
    props.enterpriseUserForm.file_company_certificate = res.data.name;
  } else {
    ElMessage({
      message: t("上传失败"),
      type: "error",
    });
    return false;
  }
};
// 公司注册证书删除
const handleCompanyCertificateImgRemove = (file) => {
  fileCompanyCertificateRef.value
    ? fileCompanyCertificateRef.value.clearFiles()
    : "";
  props.enterpriseUserForm.file_company_certificate = "";
};

// 公司组织架构上传
const handleCompanyOrganizationImgSuccess = (res) => {
  if (res.code === 0) {
    ElMessage({
      message: t("上传成功"),
      type: "success",
    });
    props.enterpriseUserForm.file_company_organization = res.data.name;
  } else {
    ElMessage({
      message: t("上传失败"),
      type: "error",
    });
    return false;
  }
};
// 公司组织架构删除
const handleCompanyOrganizationImgRemove = (file) => {
  fileCompanyOrganizationRef.value
    ? fileCompanyOrganizationRef.value.clearFiles()
    : "";
  props.enterpriseUserForm.file_company_organization = "";
};

// 最新商业登记证上传
const handleLatestRegisterImgSuccess = (res) => {
  if (res.code === 0) {
    ElMessage({
      message: t("上传成功"),
      type: "success",
    });
    props.enterpriseUserForm.file_latest_register = res.data.name;
  } else {
    ElMessage({
      message: t("上传失败"),
      type: "error",
    });
    return false;
  }
};
// 最新商业登记证删除
const handleLatestRegisterImgRemove = (file) => {
  fileLatestRegisterRef.value ? fileLatestRegisterRef.value.clearFiles() : "";
  props.enterpriseUserForm.file_latest_register = "";
};

// 最新年审报告上传
const handleLatestReportImgSuccess = (res) => {
  if (res.code === 0) {
    ElMessage({
      message: t("上传成功"),
      type: "success",
    });
    props.enterpriseUserForm.file_latest_report = res.data.name;
  } else {
    ElMessage({
      message: t("上传失败"),
      type: "error",
    });
    return false;
  }
};
// 最新年审报告删除
const handleLatestReportImgRemove = (file) => {
  fileLatestReportRef.value ? fileLatestReportRef.value.clearFiles() : "";
  props.enterpriseUserForm.file_latest_report = "";
};

// 最新财务报表上传
const handleFinancialStatementsImgSuccess = (res) => {
  if (res.code === 0) {
    ElMessage({
      message: t("上传成功"),
      type: "success",
    });
    props.enterpriseUserForm.file_financial_statements = res.data.name;
  } else {
    ElMessage({
      message: t("上传失败"),
      type: "error",
    });
    return false;
  }
};
// 最新财务报表删除
const handleFinancialStatementsImgRemove = (file) => {
  fileFinancialStatementsRef.value
    ? fileFinancialStatementsRef.value.clearFiles()
    : "";
  props.enterpriseUserForm.file_financial_statements = "";
};

// 所有持股10%以上股东有效证件上传
const handleStockCertificateImgSuccess = (res) => {
  if (res.code === 0) {
    ElMessage({
      message: t("上传成功"),
      type: "success",
    });
    props.enterpriseUserForm.file_stock_certificate = res.data.name;
  } else {
    ElMessage({
      message: t("上传失败"),
      type: "error",
    });
    return false;
  }
};
// 所有持股10%以上股东有效证件删除
const handleStockCertificateImgRemove = (file) => {
  fileStockCertificateRef.value
    ? fileStockCertificateRef.value.clearFiles()
    : "";
  props.enterpriseUserForm.file_stock_certificate = "";
};

// 开户授权签字人有效证件+签字印鉴上传
const handleKaihuZhengjianImgSuccess = (res) => {
  if (res.code === 0) {
    ElMessage({
      message: t("上传成功"),
      type: "success",
    });
    props.enterpriseUserForm.file_kaihu_zhengjian = res.data.name;
  } else {
    ElMessage({
      message: t("上传失败"),
      type: "error",
    });
    return false;
  }
};
// 开户授权签字人有效证件+签字印鉴删除
const handleKaihuZhengjianImgRemove = (file) => {
  fileStockCertificateRef.value
    ? fileStockCertificateRef.value.clearFiles()
    : "";
  props.enterpriseUserForm.file_kaihu_zhengjian = "";
};

// 开户授权签字人个人地址证明(近3个月)上传
const handleKaihuZhengjianAddrImgSuccess = (res) => {
  if (res.code === 0) {
    ElMessage({
      message: t("上传成功"),
      type: "success",
    });
    props.enterpriseUserForm.file_kaihu_zhengjian_addr = res.data.name;
  } else {
    ElMessage({
      message: t("上传失败"),
      type: "error",
    });
    return false;
  }
};
// 开户授权签字人个人地址证明(近3个月)删除
const handleKaihuZhengjianAddrImgRemove = (file) => {
  fileStockCertificateRef.value
    ? fileStockCertificateRef.value.clearFiles()
    : "";
  props.enterpriseUserForm.file_kaihu_zhengjian_addr = "";
};

// 董事地址证明(近3个月)上传
const handleBoardMemberAddressImgSuccess = (res) => {
  if (res.code === 0) {
    ElMessage({
      message: t("上传成功"),
      type: "success",
    });
    props.enterpriseUserForm.file_board_member_address = res.data.name;
  } else {
    ElMessage({
      message: t("上传失败"),
      type: "error",
    });
    return false;
  }
};
// 董事地址证明(近3个月)删除
const handleBoardMemberAddressImgRemove = (file) => {
  fileStockCertificateRef.value
    ? fileStockCertificateRef.value.clearFiles()
    : "";
  props.enterpriseUserForm.file_board_member_address = "";
};

// NVOICE范本上传
const handleNvoiceImgSuccess = (res) => {
  if (res.code === 0) {
    ElMessage({
      message: t("上传成功"),
      type: "success",
    });
    props.enterpriseUserForm.file_invoice = res.data.name;
  } else {
    ElMessage({
      message: t("上传失败"),
      type: "error",
    });
    return false;
  }
};
// NVOICE范本删除
const handleNvoiceImgRemove = (file) => {
  fileNvoiceRef.value ? fileNvoiceRef.value.clearFiles() : "";
  props.enterpriseUserForm.file_invoice = "";
};

// 公司地址证明(上传
const handleCompanyAddressImgSuccess = (res) => {
  if (res.code === 0) {
    ElMessage({
      message: t("上传成功"),
      type: "success",
    });
    props.enterpriseUserForm.file_company_address = res.data.name;
  } else {
    ElMessage({
      message: t("上传失败"),
      type: "error",
    });
    return false;
  }
};
// 公司地址证明(删除
const handleCompanyAddressImgRemove = (file) => {
  fileCompanyAddressRef.value ? fileCompanyAddressRef.value.clearFiles() : "";
  props.enterpriseUserForm.file_company_address = "";
};

// 银行对账单(上传
const handleBankStatementImgSuccess = (res) => {
  if (res.code === 0) {
    ElMessage({
      message: t("上传成功"),
      type: "success",
    });
    props.enterpriseUserForm.file_bank_statement = res.data.name;
  } else {
    ElMessage({
      message: t("上传失败"),
      type: "error",
    });
    return false;
  }
};
// 银行对账单(删除
const handleBankStatementImgRemove = (file) => {
  fileBankStatementRef.value ? fileBankStatementRef.value.clearFiles() : "";
  props.enterpriseUserForm.file_bank_statement = "";
};

// 供应商协议及发票（有效期内）(上传
const handleSupplierAgreementImgSuccess = (res) => {
  if (res.code === 0) {
    ElMessage({
      message: t("上传成功"),
      type: "success",
    });
    props.enterpriseUserForm.file_supplier_agreement = res.data.name;
  } else {
    ElMessage({
      message: t("上传失败"),
      type: "error",
    });
    return false;
  }
};
// 供应商协议及发票（有效期内）(删除
const handleSupplierAgreementImgRemove = (file) => {
  fileSupplierAgreementRef.value
    ? fileSupplierAgreementRef.value.clearFiles()
    : "";
  props.enterpriseUserForm.file_supplier_agreement = "";
};

// 销售协议及发票（有效期内）(上传
const handleSaleAgreementImgSuccess = (res) => {
  if (res.code === 0) {
    ElMessage({
      message: t("上传成功"),
      type: "success",
    });
    props.enterpriseUserForm.file_sale_agreement = res.data.name;
  } else {
    ElMessage({
      message: t("上传失败"),
      type: "error",
    });
    return false;
  }
};
// 销售协议及发票（有效期内）(删除
const handleSaleAgreementImgRemove = (file) => {
  fileSaleAgreementRef.value ? fileSaleAgreementRef.value.clearFiles() : "";
  props.enterpriseUserForm.file_sale_agreement = "";
};
// 保存
const handleSave = () => {
  formRef.value
    .validate()
    .then(() => {
      emits("submitEnterpriseUserForm", props.enterpriseUserForm);
    })
    .catch((error) => {
      console.log(error);
    });
};
// 提交
const handleSubmit = () => {
  formRef.value
    .validate()
    .then(() => {
      emits("enterprisePersonSubmit", props.enterpriseUserForm);
    })
    .catch((error) => {
      console.log(error);
    });
};
// 获取币种
const getCurrencyData = async () => {
  const res = await getCurrencyNewApi();
  currencyList.value = res.currency;
};
Promise.all([getCurrencyData()]);
</script>

<style scoped>
:deep(.el-form-item) {
  margin-bottom: 20px;
}

:deep(.el-upload-list--picture-card) {
  width: 192px;
  height: 112px;
}

:deep(.el-upload-list--picture-card .el-upload-list__item) {
  width: 192px;
  height: 112px;
}

:deep(.el-upload--picture-card) {
  width: 192px;
  height: 112px;
  display: flex;
  flex-direction: column;
  font-size: 12px;
}

:deep(.front_box .el-upload--picture-card) {
  display: none;
}

:deep(.back_box .el-upload--picture-card) {
  display: none;
}

:deep(.hand_box .el-upload--picture-card) {
  display: none;
}

.uploadDiv {
  margin-right: 30px;
}
</style>
